import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:series_play/comm/base/base_state.dart';
import 'package:series_play/comm/comm_constant.dart';
import 'package:series_play/comm/ext/context_ext.dart';
import 'package:series_play/widget/app_color.dart';
import 'package:series_play/widget/app_image.dart';
import 'package:series_play/widget/app_text.dart';

import 'controller/vip_controller.dart';

class VipPager extends StatefulWidget {
  const VipPager({super.key});

  @override
  State<VipPager> createState() => _VipPagerState();
}

class _VipPagerState extends BaseControllerState<VipPager, VipController> {
  @override
  Widget buildPage(BuildContext context) {
    return SingleChildScrollView(
      padding: const EdgeInsets.all(16).w,
      child: Column(
        children: [
          // 头像
          Row(
            children: [
              AppImage.circle(
                CommConstant.fuckImgData[1],
                borderWidth: 1,
                borderColor: Color(0x52FFFFFF),
                size: 70,
              ),
              24.horizontalSpace,
              Column(
                mainAxisSize: MainAxisSize.min,
                crossAxisAlignment: CrossAxisAlignment.start,
                children: [
                  AppText.title('用户名 刘德华驾到', color: AppColor.white),
                  12.verticalSpace,
                  AppText.secondary(
                    'VIP 有效期：2025-12-19',
                    color: AppColor.colorA4893F,
                    fontSize: 12,
                  ),
                ],
              ),
            ],
          ),
          25.verticalSpace,
          // list表
          ListView.separated(
            physics: const NeverScrollableScrollPhysics(),
            shrinkWrap: true,
            itemBuilder: (context, index) {
              return SizedBox(
                height: index == 0 ? 104.w : 122.w,
                width: double.infinity,
                child: Stack(
                  children: [
                    Positioned.fill(
                      child: Container(
                        padding: const EdgeInsets.symmetric(
                          horizontal: 20,
                          vertical: 16,
                        ).w,
                        decoration: BoxDecoration(
                          color: const Color(0xFF292B34).withValues(alpha: 0.5),
                          borderRadius: BorderRadius.circular(10).r,
                        ),
                        child: Column(
                          crossAxisAlignment: CrossAxisAlignment.start,
                          children: [
                            AppText.title('周订阅', color: AppColor.white),
                            const Spacer(),
                            Row(
                              children: [
                                AppText(
                                  '\$100.00',
                                  color: AppColor.white,
                                  fontSize: 21,
                                ),
                                8.horizontalSpace,
                                AppText(
                                  '\$2.88/天',
                                  color: AppColor.white_40,
                                  fontSize: 14,
                                ),
                              ],
                            ),
                            const Spacer(),
                            AppText.title(
                              '享受7天无限制观看体验',
                              color: AppColor.colorA4893F,
                              fontSize: 12,
                            ),
                           index != 0 ?  const Spacer() : Container(),
                            index != 0 ?   AppText.title(
                              '后续按照\$19.00/周 订阅',
                              color: AppColor.white_40,
                              fontSize: 12,
                            ): Container(),
                          ],
                        ),
                      ),
                    ),

                    Positioned(
                      right: 0,
                      top: 0,
                      child: index != 0 ? Container(
                          padding:const EdgeInsets.symmetric(horizontal: 16 , vertical: 1).w,
                          decoration: BoxDecoration(
                              color: const Color(0xFFF64729),
                              borderRadius: BorderRadius.only(
                                bottomLeft: Radius.circular(10).r,
                                topRight: Radius.circular(10).r,
                              )
                          ),
                          child: AppText('优惠倒计时：10:00:00' , fontSize: 12, color: Colors.white)) : Container(),
                    ),
                  ],
                ),
              );
            },
            separatorBuilder: (context, index) {
              return 12.verticalSpace;
            },
            itemCount: 3,
          ),
          66.verticalSpace,
          // 底部说明
          Padding(
            padding: const EdgeInsets.symmetric(horizontal: 8).w,
            child: AppText(
              context.tr.vipSubscribeRule,
              color: AppColor.white_40,
              fontSize: 12,
              lineHeight: 1.6,
            ),
          ),
        ],
      ),
    );
  }

  @override
  VipController createController() {
    return VipController();
  }

  @override
  String getTitle() {
    return '订阅详情';
  }

  @override
  bool showDefaultBackground() {
    return true;
  }
}
